/*
 * @authors :Bin Mei
 * @date    :2017-05-22
 * @description：react-redux-chat  -> 仿微信聊天工具
 */

import { StaticToast} from 'pjh-mobile-ui';
import { mFetch} from 'min-bridge';

export const  USER_INIT = "USER_INIT";
export const  SET_DATA = "SET_DATA";
export const TEST_DATA = "TEST_DATA";


let user =  {
	//初始化接口，如刷新后
	user_init:(data)=>{
		return {
			type:USER_INIT,
			data
		}
	},
	set_data:(data)=>{
		return {
			type:SET_DATA,
			data
		}
	},
	mock_data:(options)=>{
		return (dispatch)=>{
			let {data} = options;
			mFetch.fetchJson({
				type:"POST",
				url:"/phjApi/mock/api/test/userToken",
				data,
				success:res=>{
					console.log(res);
					// StaticToast.error("res.message");
					/*if(res.code == 0){
						let {result}=res;
						dispatch({
							type:TEST_DATA,
							data:(result||{})
						});
					}else{
						StaticToast.error(res.message);
					}*/
				},
			});

		};
	},
	
	test_data:(options)=>{
		return (dispatch)=>{
			let {data} = options;
			mFetch.fetchJson({
				type:"POST",
				url:"http://192.168.2.214:8087/api",
				// url:"/phjApi/app_api/api",
				data,
				success:res=>{
					console.log(res);
					/*if(res.code == 0){
						let {result}=res;
						dispatch({
							type:TEST_DATA,
							data:(result||{})
						});
					}else{
						StaticToast.error(res.message);
					}*/
				},
			});

		};
	}
	
	
};
export default user;


